import java.util.*;

class Brand {
	private String name;
	public Brand(String name){
		this.name=name;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	@Override
	public String toString() {
		return "Brand [name=" + name + "]";
	}
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((name == null) ? 0 : name.hashCode());
		return result;
	}
	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Brand other = (Brand) obj;
		if (name == null) {
			if (other.name != null)
				return false;
		} else if (!name.equals(other.name))
			return false;
		return true;
	}
	
}
class  Car {
	private String id;
	private Brand brand;
	static int n=1;
	{
		id=Integer.toString(n++);
	}
    
     static{
		System.out.println("0 car");
	} 
	public Car(Brand brand){
		this.brand=brand;
	}
	public String getId() {
		return id;
	}
	public void setId(String id) {
		this.id = id;
	}
	public Brand getBrand() {
		return brand;
	}
	public void setBrand(Brand brand) {
		this.brand = brand;
	}
	@Override
	public String toString() {
		return "Car [id=" + id + ", brand=" + brand + "]";
	}
	
}
public class Exam2 {
	
	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		while(in.hasNext()){
			int n=in.nextInt();
			ArrayList<Car>car=new ArrayList<Car>();
			ArrayList<Brand> brand1=new ArrayList<Brand>();
			for (int i = 0; i < n; i++) {
				String temp=in.next();
				Brand str= new Brand(temp);
				if(!(brand1.contains(str))){
					brand1.add(str);
					car.add(new Car(str));
				}
				else {
					System.out.printf(temp+" exist");
				}
			}
			for (int i = 0; i < brand1.size(); i++) {
				System.out.println(car.get(i));
			}
			System.out.println(Arrays.toString(Car.class.getConstructors()));
		}
        in.close();
	}
}
